package org.soundsync.ebook.ui.settings

import android.app.Application
import android.content.Context
import android.util.Log
import android.view.View
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.Battery5Bar
import androidx.compose.material.icons.filled.Contrast
import androidx.compose.material.icons.filled.DarkMode
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.FormatSize
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Keyboard
import androidx.compose.material.icons.filled.Language
import androidx.compose.material.icons.filled.MenuBook
import androidx.compose.material.icons.filled.Palette
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.Style
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Slider
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.lifecycle.viewmodel.compose.viewModel
import org.soundsync.ebook.R
import org.soundsync.ebook.ui.theme.Primary
import org.soundsync.ebook.util.TtsManager

/**
 * 设置屏幕
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen() {
    val context = LocalContext.current
    val application = LocalContext.current.applicationContext as Application
    val viewModel = viewModel<SettingsViewModel>(
        factory = SettingsViewModelFactory(context)
    )
    
    // 确保每次进入设置界面时，重置readBookId并更新TTS同步状态
    LaunchedEffect(Unit) {
        // 重置全局阅读位置
        val mainActivity = org.soundsync.ebook.MainActivity.getInstance()
        mainActivity?.updateReadingPosition(null, 0, 0)
        
        // 更新TTS同步状态
        val ttsManager = TtsManager.getInstance(context)
        ttsManager.updateSyncPageState()
        
        Log.d("SettingsScreen", "进入设置界面，重置readBookId为null，更新IsSyncPageState=${ttsManager.isSyncPageState.value}")
    }
    
    val settingsState by viewModel.uiState.collectAsState()
    
    // 对话框状态
    var showLanguageDialog by remember { mutableStateOf(false) }
    var showThemeDialog by remember { mutableStateOf(false) }
    var showThemeStyleDialog by remember { mutableStateOf(false) }
    var showFontSizeDialog by remember { mutableStateOf(false) }
    var showCoverStyleDialog by remember { mutableStateOf(false) }
    var showColorDialog by remember { mutableStateOf(false) }
    var showBackgroundDialog by remember { mutableStateOf(false) }
    var showAboutDialog by remember { mutableStateOf(false) }
    
    // 检查系统电池优化状态
    val isBatteryOptimizationDisabled = remember { mutableStateOf(viewModel.checkBatteryOptimizationStatus()) }
    
    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text(stringResource(R.string.settings)) },
                colors = TopAppBarDefaults.topAppBarColors(
                    containerColor = MaterialTheme.colorScheme.surface
                ),
                modifier = Modifier.height(32.dp)
            )
        }
    ) { paddingValues ->
        LazyColumn(
            modifier = Modifier
                .fillMaxSize()
                .padding(paddingValues)
                .padding(horizontal = 16.dp),
            verticalArrangement = Arrangement.spacedBy(8.dp)
        ) {
            // 语言设置
            item {
                SettingsCategoryTitle(title = stringResource(R.string.language_settings))
                SettingsItem(
                    icon = Icons.Default.Language,
                    title = stringResource(R.string.language),
                    subtitle = getLanguageText(settingsState.language),
                    onClick = { showLanguageDialog = true }
                )
            }
            
            // 主题模式
            item {
                SettingsCategoryTitle(title = stringResource(R.string.theme_mode))
                SettingsItem(
                    icon = Icons.Default.DarkMode,
                    title = stringResource(R.string.theme),
                    subtitle = getThemeText(settingsState.theme),
                    onClick = { showThemeDialog = true }
                )
            }
            
            // 主题样式
            item {
                SettingsCategoryTitle(title = stringResource(R.string.theme_style))
                SettingsItem(
                    icon = Icons.Default.FormatSize,
                    title = stringResource(R.string.font_size),
                    subtitle = getFontSizeText(settingsState.fontSize),
                    onClick = { showFontSizeDialog = true }
                )
                SettingsItem(
                    icon = Icons.Default.Style,
                    title = stringResource(R.string.cover_settings),
                    subtitle = getCoverStyleText(settingsState.coverStyle),
                    onClick = { showCoverStyleDialog = true }
                )
                SettingsItem(
                    icon = Icons.Default.Palette,
                    title = stringResource(R.string.primary_color),
                    subtitle = stringResource(R.string.primary_color_subtitle),
                    onClick = { showColorDialog = true },
                    endContent = {
                        Box(
                            modifier = Modifier
                                .size(24.dp)
                                .clip(CircleShape)
                                .background(Color(android.graphics.Color.parseColor(settingsState.primaryColor)))
                        )
                    }
                )
                SettingsItem(
                    icon = Icons.Default.Contrast,
                    title = stringResource(R.string.background_color),
                    subtitle = stringResource(R.string.background_color_subtitle),
                    onClick = { showBackgroundDialog = true },
                    endContent = {
                        Box(
                            modifier = Modifier
                                .size(24.dp)
                                .clip(CircleShape)
                                .background(Color(android.graphics.Color.parseColor(settingsState.backgroundColor)))
                        )
                    }
                )
            }
            
            // 其他
            item {
                SettingsCategoryTitle(title = stringResource(R.string.other))
                
                // 电池优化开关
                SettingsSwitchItem(
                    icon = Icons.Default.Battery5Bar,
                    title = stringResource(R.string.disable_battery_optimization),
                    subtitle = stringResource(R.string.battery_optimization_subtitle),
                    isChecked = isBatteryOptimizationDisabled.value,
                    onCheckedChange = { checked ->
                        viewModel.setBatteryOptimization(checked)
                        // 更新UI状态
                        isBatteryOptimizationDisabled.value = checked
                    }
                )
                
                // 后台运行开关
                SettingsSwitchItem(
                    icon = Icons.Default.MenuBook,
                    title = stringResource(R.string.allow_background_running),
                    subtitle = stringResource(R.string.background_running_subtitle),
                    isChecked = settingsState.backgroundRunningEnabled,
                    onCheckedChange = { checked ->
                        viewModel.setBackgroundRunning(checked)
                    }
                )
                
                SettingsItem(
                    icon = Icons.Default.Info,
                    title = stringResource(R.string.about),
                    subtitle = stringResource(R.string.about_subtitle),
                    onClick = { showAboutDialog = true }
                )
            }
        }
        
        // 语言对话框
        if (showLanguageDialog) {
            SettingsOptionDialog(
                title = stringResource(R.string.select_language),
                options = listOf(
                    stringResource(R.string.follow_system),
                    stringResource(R.string.simplified_chinese),
                    stringResource(R.string.english)
                ),
                selectedOption = settingsState.language,
                onOptionSelected = { viewModel.setLanguage(it) },
                onDismiss = { showLanguageDialog = false }
            )
        }
        
        // 主题对话框
        if (showThemeDialog) {
            SettingsOptionDialog(
                title = stringResource(R.string.theme),
                options = listOf(
                    stringResource(R.string.light_mode),
                    stringResource(R.string.dark_mode),
                    stringResource(R.string.system_mode)
                ),
                selectedOption = settingsState.theme,
                onOptionSelected = { viewModel.setTheme(it) },
                onDismiss = { showThemeDialog = false }
            )
        }
        
        // 字体大小对话框
        if (showFontSizeDialog) {
            SettingsOptionDialog(
                title = stringResource(R.string.select_font_size),
                options = listOf(
                    stringResource(R.string.font_size_small),
                    stringResource(R.string.font_size_medium),
                    stringResource(R.string.font_size_large)
                ),
                selectedOption = settingsState.fontSize,
                onOptionSelected = { viewModel.setFontSize(it) },
                onDismiss = { showFontSizeDialog = false }
            )
        }
        
        // 封面样式对话框
        if (showCoverStyleDialog) {
            SettingsOptionDialog(
                title = stringResource(R.string.select_cover_style),
                options = listOf(
                    stringResource(R.string.cover_style_default),
                    stringResource(R.string.cover_style_card),
                    stringResource(R.string.cover_style_material)
                ),
                selectedOption = settingsState.coverStyle,
                onOptionSelected = { viewModel.setCoverStyle(it) },
                onDismiss = { showCoverStyleDialog = false }
            )
        }
        
        // 主色调对话框
        if (showColorDialog) {
            ColorPickerDialog(
                title = stringResource(R.string.select_primary_color),
                currentColor = Color(android.graphics.Color.parseColor(settingsState.primaryColor)),
                onColorSelected = { 
                    val colorString = String.format("#%06X", 0xFFFFFF and it.toArgb())
                    viewModel.setPrimaryColor(colorString)
                },
                onDismiss = { showColorDialog = false }
            )
        }
        
        // 背景色对话框
        if (showBackgroundDialog) {
            ColorPickerDialog(
                title = stringResource(R.string.select_background_color),
                currentColor = Color(android.graphics.Color.parseColor(settingsState.backgroundColor)),
                onColorSelected = { 
                    val colorString = String.format("#%06X", 0xFFFFFF and it.toArgb())
                    viewModel.setBackgroundColor(colorString)
                },
                onDismiss = { showBackgroundDialog = false }
            )
        }
        
        // 关于对话框
        if (showAboutDialog) {
            AboutDialog(
                onDismiss = { showAboutDialog = false }
            )
        }
    }
}

/**
 * 设置分类标题
 */
@Composable
fun SettingsCategoryTitle(title: String) {
    Text(
        text = title,
        style = MaterialTheme.typography.titleMedium,
        color = MaterialTheme.colorScheme.primary,
        modifier = Modifier.padding(top = 16.dp, bottom = 8.dp)
    )
}

/**
 * 设置项
 */
@Composable
fun SettingsItem(
    icon: ImageVector,
    title: String,
    subtitle: String,
    onClick: () -> Unit,
    endContent: @Composable (() -> Unit)? = {
        Icon(
            imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.onSurfaceVariant
        )
    }
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .clip(RoundedCornerShape(8.dp))
            .clickable(onClick = onClick)
            .padding(vertical = 12.dp, horizontal = 8.dp),
        verticalAlignment = Alignment.CenterVertically
    ) {
        Icon(
            imageVector = icon,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.primary,
            modifier = Modifier.size(24.dp)
        )
        
        Spacer(modifier = Modifier.width(16.dp))
        
        Column(
            modifier = Modifier.weight(1f)
        ) {
            Text(
                text = title,
                style = MaterialTheme.typography.bodyLarge,
                color = MaterialTheme.colorScheme.onSurface
            )
            
            Text(
                text = subtitle,
                style = MaterialTheme.typography.bodyMedium,
                color = MaterialTheme.colorScheme.onSurfaceVariant
            )
        }
        
        endContent?.invoke()
    }
}

/**
 * 设置开关项
 */
@Composable
fun SettingsSwitchItem(
    icon: ImageVector,
    title: String,
    subtitle: String,
    isChecked: Boolean,
    onCheckedChange: (Boolean) -> Unit
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .clip(RoundedCornerShape(8.dp))
            .clickable { onCheckedChange(!isChecked) }
            .padding(vertical = 12.dp, horizontal = 8.dp),
        verticalAlignment = Alignment.CenterVertically
    ) {
        Icon(
            imageVector = icon,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.primary,
            modifier = Modifier.size(24.dp)
        )
        
        Spacer(modifier = Modifier.width(16.dp))
        
        Column(
            modifier = Modifier.weight(1f)
        ) {
            Text(
                text = title,
                style = MaterialTheme.typography.bodyLarge,
                color = MaterialTheme.colorScheme.onSurface
            )
            
            Text(
                text = subtitle,
                style = MaterialTheme.typography.bodyMedium,
                color = MaterialTheme.colorScheme.onSurfaceVariant
            )
        }
        
        Switch(
            checked = isChecked,
            onCheckedChange = onCheckedChange
        )
    }
}

/**
 * 选项对话框
 */
@Composable
fun SettingsOptionDialog(
    title: String,
    options: List<String>,
    selectedOption: Int,
    onOptionSelected: (Int) -> Unit,
    onDismiss: () -> Unit
) {
    AlertDialog(
        onDismissRequest = onDismiss,
        title = { Text(text = title) },
        text = {
            Column {
                options.forEachIndexed { index, option ->
                    Row(
                        modifier = Modifier
                            .fillMaxWidth()
                            .clickable { 
                                onOptionSelected(index)
                                onDismiss() 
                            }
                            .padding(vertical = 12.dp),
                        verticalAlignment = Alignment.CenterVertically
                    ) {
                        RadioButton(
                            selected = selectedOption == index,
                            onClick = { 
                                onOptionSelected(index)
                                onDismiss() 
                            }
                        )
                        
                        Spacer(modifier = Modifier.width(8.dp))
                        
                        Text(text = option)
                    }
                }
            }
        },
        confirmButton = {
            TextButton(onClick = onDismiss) {
                Text("取消")
            }
        }
    )
}

/**
 * 颜色选择对话框
 */
@Composable
fun ColorPickerDialog(
    title: String,
    currentColor: Color,
    onColorSelected: (Color) -> Unit,
    onDismiss: () -> Unit
) {
    // 色彩选项
    val colorOptions = listOf(
        Color(0xFFE57373), // 红色
        Color(0xFFF06292), // 粉红色
        Color(0xFFBA68C8), // 紫色
        Color(0xFF9575CD), // 深紫色
        Color(0xFF7986CB), // 靛蓝色
        Color(0xFF64B5F6), // 蓝色
        Color(0xFF4FC3F7), // 浅蓝色
        Color(0xFF4DD0E1), // 青色
        Color(0xFF4DB6AC), // 蓝绿色
        Color(0xFF81C784), // 绿色
        Color(0xFFAED581), // 浅绿色
        Color(0xFFFF8A65), // 橙色
        Color(0xFF90A4AE), // 蓝灰色
        Color(0xFF0091EA), // 亮蓝色
        Color(0xFF1E3A5F), // 深蓝色
        Color(0xFF212121)  // 黑色
    )
    
    var selectedColor by remember { mutableStateOf(currentColor) }
    
    Dialog(onDismissRequest = onDismiss) {
        Surface(
            shape = RoundedCornerShape(16.dp),
            color = MaterialTheme.colorScheme.surface
        ) {
            Column(
                modifier = Modifier.padding(20.dp),
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                Text(
                    text = title,
                    style = MaterialTheme.typography.titleLarge
                )
                
                Spacer(modifier = Modifier.height(20.dp))
                
                // 颜色展示
                Box(
                    modifier = Modifier
                        .size(60.dp)
                        .clip(CircleShape)
                        .background(selectedColor)
                        .padding(4.dp)
                )
                
                Spacer(modifier = Modifier.height(20.dp))
                
                // 颜色选项网格
                Column(
                    verticalArrangement = Arrangement.spacedBy(8.dp)
                ) {
                    for (i in 0 until 4) {
                        Row(
                            horizontalArrangement = Arrangement.spacedBy(8.dp)
                        ) {
                            for (j in 0 until 4) {
                                val index = i * 4 + j
                                if (index < colorOptions.size) {
                                    val color = colorOptions[index]
                                    Box(
                                        modifier = Modifier
                                            .size(40.dp)
                                            .clip(CircleShape)
                                            .background(color)
                                            .clickable {
                                                selectedColor = color
                                            }
                                            .padding(4.dp)
                                    )
                                } else {
                                    Box(modifier = Modifier.size(40.dp))
                                }
                            }
                        }
                    }
                }
                
                Spacer(modifier = Modifier.height(20.dp))
                
                Row(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.End
                ) {
                    TextButton(
                        onClick = onDismiss
                    ) {
                        Text("取消")
                    }
                    
                    TextButton(
                        onClick = {
                            onColorSelected(selectedColor)
                            onDismiss()
                        }
                    ) {
                        Text("确定")
                    }
                }
            }
        }
    }
}

/**
 * 关于对话框
 */
@Composable
fun AboutDialog(
    onDismiss: () -> Unit
) {
    AlertDialog(
        onDismissRequest = onDismiss,
        title = null, // 移除标题，使用自定义布局
        text = {
            Column(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(top = 8.dp),
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                // 1. LOGO图标（居中）
                Box(
                    modifier = Modifier
                        .size(100.dp)
                        .clip(CircleShape)
                        .background(MaterialTheme.colorScheme.primary.copy(alpha = 0.9f))
                        .border(2.dp, MaterialTheme.colorScheme.primary.copy(alpha = 0.5f), CircleShape)
                        .padding(16.dp),
                    contentAlignment = Alignment.Center
                ) {
                    Icon(
                        imageVector = Icons.Default.MenuBook,
                        contentDescription = "App Logo",
                        tint = Color.White,
                        modifier = Modifier.size(56.dp)
                    )
                }
                
                Spacer(modifier = Modifier.height(20.dp))
                
                // 2. 应用中文名
                Text(
                    text = "随声阅",
                    style = MaterialTheme.typography.headlineMedium.copy(
                        fontWeight = FontWeight.Bold,
                        letterSpacing = 2.sp
                    ),
                    textAlign = TextAlign.Center,
                    color = MaterialTheme.colorScheme.primary
                )
                
                Spacer(modifier = Modifier.height(8.dp))
                
                // 3. 应用英文名和版本号
                Text(
                    text = "SoundSync v0.36",
                    style = MaterialTheme.typography.bodyMedium.copy(
                        fontStyle = FontStyle.Italic
                    ),
                    color = MaterialTheme.colorScheme.onSurfaceVariant
                )
                
                Spacer(modifier = Modifier.height(16.dp))
                
                Divider(
                    modifier = Modifier
                        .fillMaxWidth(0.8f)
                        .padding(vertical = 8.dp),
                    thickness = 1.dp,
                    color = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f)
                )
                
                Spacer(modifier = Modifier.height(16.dp))
                
                // 4. 应用简介
                Text(
                    text = "本应用提供电子书导入、文本输入和阅读功能，同时支持TTS朗读和合成语音功能，目前应用仍在不断升级和完善中，欢迎使用并提出改进意见或建议。",
                    style = MaterialTheme.typography.bodyMedium,
                    textAlign = TextAlign.Center,
                    modifier = Modifier.padding(horizontal = 16.dp),
                    lineHeight = 24.sp
                )
                
                Spacer(modifier = Modifier.height(20.dp))
                
                // 5. 联系作者
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                    modifier = Modifier
                        .padding(top = 8.dp)
                        .clip(RoundedCornerShape(20.dp))
                        .background(MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.3f))
                        .padding(horizontal = 16.dp, vertical = 8.dp)
                ) {
                    Icon(
                        imageVector = Icons.Default.Person,
                        contentDescription = "作者信息",
                        tint = MaterialTheme.colorScheme.primary,
                        modifier = Modifier.size(20.dp)
                    )
                    Spacer(modifier = Modifier.width(8.dp))
                    Text(
                        text = "作者：Hunt2035",
                        style = MaterialTheme.typography.bodyMedium,
                        color = MaterialTheme.colorScheme.primary
                    )
                }
            }
        },
        confirmButton = {
            Row(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(bottom = 16.dp),
                horizontalArrangement = Arrangement.Center
            ) {
                Button(
                    onClick = onDismiss,
                    shape = RoundedCornerShape(20.dp),
                    colors = ButtonDefaults.buttonColors(
                        containerColor = MaterialTheme.colorScheme.primary
                    )
                ) {
                    Text("确定", modifier = Modifier.padding(horizontal = 16.dp))
                }
            }
        },
        containerColor = MaterialTheme.colorScheme.surface,
        shape = RoundedCornerShape(24.dp),
        modifier = Modifier
            .padding(16.dp)
            .shadow(8.dp, RoundedCornerShape(24.dp))
    )
}

/**
 * 获取语言文本
 */
@Composable
fun getLanguageText(language: Int): String {
    return when (language) {
        SettingsViewModel.LANGUAGE_SYSTEM -> stringResource(R.string.follow_system)
        SettingsViewModel.LANGUAGE_CHINESE -> stringResource(R.string.simplified_chinese)
        SettingsViewModel.LANGUAGE_ENGLISH -> stringResource(R.string.english)
        else -> "未知"
    }
}

/**
 * 获取主题文本
 */
@Composable
fun getThemeText(theme: Int): String {
    return when (theme) {
        SettingsViewModel.THEME_LIGHT -> stringResource(R.string.light_mode)
        SettingsViewModel.THEME_DARK -> stringResource(R.string.dark_mode)
        SettingsViewModel.THEME_SYSTEM -> stringResource(R.string.system_mode)
        else -> "未知"
    }
}

/**
 * 获取字体大小文本
 */
@Composable
fun getFontSizeText(fontSize: Int): String {
    return when (fontSize) {
        SettingsViewModel.FONT_SIZE_SMALL -> stringResource(R.string.font_size_small)
        SettingsViewModel.FONT_SIZE_MEDIUM -> stringResource(R.string.font_size_medium)
        SettingsViewModel.FONT_SIZE_LARGE -> stringResource(R.string.font_size_large)
        else -> stringResource(R.string.unknown)
    }
}

/**
 * 获取封面样式文本
 */
@Composable
fun getCoverStyleText(coverStyle: Int): String {
    return when (coverStyle) {
        SettingsViewModel.COVER_STYLE_DEFAULT -> stringResource(R.string.cover_style_default)
        SettingsViewModel.COVER_STYLE_CARD -> stringResource(R.string.cover_style_card)
        SettingsViewModel.COVER_STYLE_MATERIAL -> stringResource(R.string.cover_style_material)
        else -> stringResource(R.string.unknown)
    }
} 